﻿using System;
namespace Moonlite.ExtensionApi
{
    public static class HexUtils
    {
        public static string ConvertStringToHexString(string input)
        {
            input = input.Trim();
            string output = "";
            char[] values = input.ToCharArray();
            Array.ForEach(values, letter =>
            {
                int value = Convert.ToInt32(letter);
                output += String.Format("{0:X} ", value);
            });

            return output;
        }

        public static string ConvertHexStringToString(string input)
        {
            input = input.Trim();
            string output = "";
            string[] hexValuesSplit = input.Split(' ');
            Array.ForEach(hexValuesSplit, hex =>
            {
                int value = Convert.ToInt32(hex, 16);
                string stringValue = Char.ConvertFromUtf32(value);
                output += stringValue;
            });

            return output;
        }
    }
}
